The present disclosure relates to a semiconductor device and, for example, relates to a semiconductor device such as a microcomputer having a nonvolatile memory.
In a microcomputer having a central processing unit, a flash memory, and the like, a program developed by a set maker or the like using the microcomputer, parameter data, and the like is written in a flash memory and used.
To such stored information, there is a fear of an unauthorized access. For example, when such a microcomputer is coupled to an external writing device (also called a programmer) and has an operation mode in which data can be erased/written from/to a storage region in a flash memory, by setting the operation mode, a program stored in the storage region can be relatively easily read and taken to the outside.
That is, the microcomputer is set as a single flash memory in appearance and set in a state where it can operate according to a read access command from the outside.
Therefore, a technique for security protection to prevent an authorized access to such stored information is necessary.
Japanese Unexamined Patent Application Publication No. 2003-44457 proposes a method which permits data writing after execution of erasure of all of data to satisfy both convenience of data rewriting and data leakage. Although security is temporarily cancelled to permit data writing, by erasing all of data in advance, protected data is prevented from being leaked.